<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="../vue.js"> </script>
</head>
<body>
  <!-- 
    watch 数据是新的的dom还是修改之前的
  -->
  <div id="app">
    <p ref="p">{{num}}</p>
    <button @click="change">change</button>
  </div>
  
  <script>
    /*

    */ 
    new Vue({
      el: "#app",
      data: {
        num: 123 
      },
      methods: {
        change() {
          this.num ++
        }
      },
      beforeUpdate() {
        // this dom data 都有
        // dom是更新之前
        console.log('数据更新之前')
        console.log(this.num)
        console.log(this.$refs.p.innerHTML)
      },
      updated() {
        // this dom data 都有
        // dom是更新之后
        // 修改数据小心产生死循环
        console.log('数据更新结束')
        console.log(this.num)
        console.log(this.$refs.p.innerHTML)
        this.num = 99
      }
    })

  </script>
</body>
</html>